package defpackage; import android.annotation.TargetApi; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.Color; import android.net.Uri; import android.net.http.SslError; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.SystemClock; import android.support.v4.app.NotificationCompat; import android.text.TextUtils; import android.view.MotionEvent; import android.view.View; import android.webkit.SslErrorHandler; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.FrameLayout; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; import com.iflytek.cloud.SpeechUtility; import com.mopub.mobileads.VastExtensionXmlManager; import com.tencent.open.web.security.JniInterface; import defpackage.ztr; import java.io.File; import java.util.HashMap; import java.util.List; import java.util.Locale; import org.eclipse.paho.client.mqttv3.internal.ClientDefaults; import org.json.JSONException; import org.json.JSONObject; /* renamed from: ztq reason: default package */ public final class ztq extends Dialog { private b BJK; private FrameLayout BJL; private LinearLayout BJM; private FrameLayout BJN; private ProgressBar BJO; com.tencent.open.c.c BJP; private zve BJQ; private long BJR = 30000; private HashMap<String, Runnable> BJS; private zxj BJz; private String a; private Handler d; private String i; private Context k; private boolean m = false; private int n; private String o; private String p; private long q = 0; /* renamed from: ztq$a */ class a extends WebViewClient { private a() { } /* synthetic */ a(ztq ztq, byte b) { this(); } public final void onPageFinished(WebView webView, String str) { super.onPageFinished(webView, str); zue.a("openSDK_LOG.AuthDialog", "-->onPageFinished, url: " + str); ztq.this.BJN.setVisibility(8); if (ztq.this.BJP != null) { ztq.this.BJP.setVisibility(0); } if (!TextUtils.isEmpty(str)) { ztq.this.d.removeCallbacks((Runnable) ztq.this.BJS.remove(str)); } } public final void onPageStarted(WebView webView, String str, Bitmap bitmap) { zue.a("openSDK_LOG.AuthDialog", "-->onPageStarted, url: " + str); super.onPageStarted(webView, str, bitmap); ztq.this.BJN.setVisibility(0); ztq.this.q = SystemClock.elapsedRealtime(); if (!TextUtils.isEmpty(ztq.this.o)) { ztq.this.d.removeCallbacks((Runnable) ztq.this.BJS.remove(ztq.this.o)); } ztq.this.o = str; d dVar = new d(ztq.this.o); ztq.this.BJS.put(str, dVar); ztq.this.d.postDelayed(dVar, 120000); } public final void onReceivedError(WebView webView, int i, String str, String str2) { super.onReceivedError(webView, i, str, str2); zue.c("openSDK_LOG.AuthDialog", "-->onReceivedError, errorCode: " + i + " | description: " + str); if (!zuz.b(ztq.this.k)) { ztq.this.BJK.onError(new zxl(9001, "当前网络不可用,请稍后重试!", str2)); ztq.this.dismiss(); } else if (!ztq.this.o.startsWith("http://qzs.qq.com/open/mobile/login/qzsjump.html?")) { long elapsedRealtime = SystemClock.elapsedRealtime() - ztq.this.q; if (ztq.this.n > 0 || elapsedRealtime >= ztq.this.BJR) { ztq.this.BJP.loadUrl(ztq.o(ztq.this)); return; } ztq.m(ztq.this); ztq.this.d.postDelayed(new Runnable() { /* class defpackage.ztq.a.AnonymousClass1 */ public final void run() { ztq.this.BJP.loadUrl(ztq.this.o); } }, 500); } else { ztq.this.BJK.onError(new zxl(i, str, str2)); ztq.this.dismiss(); } } @TargetApi(8) public final void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) { sslErrorHandler.cancel(); ztq.this.BJK.onError(new zxl(sslError.getPrimaryError(), "请求不合法,请检查手机安全设置,如系统时间、代理等。", "ssl error")); ztq.this.dismiss(); } @Override // android.webkit.WebViewClient public final boolean shouldOverrideUrlLoading(WebView webView, String str) { zue.a("openSDK_LOG.AuthDialog", "-->Redirect URL: " + str); if (str.startsWith("auth://browser")) { JSONObject agw = zuz.agw(str); ztq.this.m = ztq.b(ztq.this); if (!ztq.this.m) { if (agw.optString("fail_cb", null) != null) { ztq.this.BJP.loadUrl("javascript:" + agw.optString("fail_cb") + "(" + "" + ");void(" + System.currentTimeMillis() + ");"); } else if (agw.optInt("fall_to_wv") == 1) { ztq.a(ztq.this, (Object) (ztq.this.a.indexOf("?") >= 0 ? "&" : "?")); ztq.a(ztq.this, (Object) "browser_error=1"); ztq.this.BJP.loadUrl(ztq.this.a); } else { String optString = agw.optString("redir", null); if (optString != null) { ztq.this.BJP.loadUrl(optString); } } } return true; } else if (str.startsWith("auth://tauth.qq.com/")) { ztq.this.BJK.onComplete(zuz.agw(str)); ztq.this.dismiss(); return true; } else if (str.startsWith("auth://cancel")) { ztq.this.BJK.onCancel(); ztq.this.dismiss(); return true; } else if (str.startsWith("auth://close")) { ztq.this.dismiss(); return true; } else if (str.startsWith("download://")) { try { Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(Uri.decode(str.substring(11)))); intent.addFlags(ClientDefaults.MAX_MSG_SIZE); ztq.this.k.startActivity(intent); } catch (Exception e) { zue.j("openSDK_LOG.AuthDialog", "-->start download activity exception, e: ", e); } return true; } else if (str.startsWith("auth://progress")) { try { List<String> pathSegments = Uri.parse(str).getPathSegments(); if (pathSegments.isEmpty()) { return true; } int intValue = Integer.valueOf(pathSegments.get(0)).intValue(); if (intValue == 0) { ztq.this.BJN.setVisibility(8); ztq.this.BJP.setVisibility(0); } else if (intValue == 1) { ztq.this.BJN.setVisibility(0); } return true; } catch (Exception e2) { return true; } } else if (str.startsWith("auth://onLoginSubmit")) { try { List<String> pathSegments2 = Uri.parse(str).getPathSegments(); if (!pathSegments2.isEmpty()) { ztq.this.p = pathSegments2.get(0); } } catch (Exception e3) { } return true; } else if (ztq.this.BJQ.e(ztq.this.BJP, str)) { return true; } else { zue.c("openSDK_LOG.AuthDialog", "-->Redirect URL: return false"); return false; } } } /* access modifiers changed from: package-private */ /* renamed from: ztq$b */ public class b implements zxj { String a; String b; private String d; private zxj e; public b(String str, String str2, String str3, zxj zxj) { this.d = str; this.a = str2; this.b = str3; this.e = zxj; } @Override // defpackage.zxj public final void onCancel() { if (this.e != null) { this.e.onCancel(); this.e = null; } } @Override // defpackage.zxj public final void onComplete(Object obj) { JSONObject jSONObject = (JSONObject) obj; zup.gSL().a(this.d + "_H5", SystemClock.elapsedRealtime(), 0, 0, jSONObject.optInt(SpeechUtility.TAG_RESOURCE_RET, -6), this.a, false); if (this.e != null) { this.e.onComplete(jSONObject); this.e = null; } } @Override // defpackage.zxj public final void onError(zxl zxl) { String str = zxl.gCV != null ? zxl.gCV + this.a : this.a; zup.gSL().a(this.d + "_H5", SystemClock.elapsedRealtime(), 0, 0, zxl.errorCode, str, false); ztq.a(ztq.this, str); if (this.e != null) { this.e.onError(zxl); this.e = null; } } } /* renamed from: ztq$c */ class c extends Handler { private b BJK; public c(b bVar, Looper looper) { super(looper); this.BJK = bVar; } public final void handleMessage(Message message) { switch (message.what) { case 1: b bVar = this.BJK; String str = (String) message.obj; try { bVar.onComplete(zuz.agx(str)); return; } catch (JSONException e) { e.printStackTrace(); bVar.onError(new zxl(-4, "服务器返回数据格式有误!", str)); return; } case 2: this.BJK.onCancel(); return; case 3: ztq.a(ztq.this.k, (String) message.obj); return; default: return; } } } /* renamed from: ztq$d */ class d implements Runnable { String a = ""; public d(String str) { this.a = str; } public final void run() { zue.a("openSDK_LOG.AuthDialog", "-->timeoutUrl: " + this.a + " | mRetryUrl: " + ztq.this.o); if (this.a.equals(ztq.this.o)) { ztq.this.BJK.onError(new zxl(9002, "请求页面超时,请稍后重试!", ztq.this.o)); ztq.this.dismiss(); } } } static { try { Context a2 = zuu.a(); if (a2 == null) { zue.c("openSDK_LOG.AuthDialog", "-->load lib fail, because context is null:" + zto.BJy); } else if (new File(a2.getFilesDir().toString() + "/" + zto.BJy).exists()) { System.load(a2.getFilesDir().toString() + "/" + zto.BJy); zue.c("openSDK_LOG.AuthDialog", "-->load lib success:" + zto.BJy); } else { zue.c("openSDK_LOG.AuthDialog", "-->fail, because so is not exists:" + zto.BJy); } } catch (Exception e) { zue.j("openSDK_LOG.AuthDialog", "-->load lib error:" + zto.BJy, e); } } public ztq(Context context, String str, String str2, zxj zxj, ztp ztp) { super(context, 16973840); this.k = context; this.a = str2; this.BJK = new b(str, str2, ztp.a, zxj); this.d = new c(this.BJK, context.getMainLooper()); this.BJz = zxj; this.i = str; this.BJQ = new zve(); getWindow().setSoftInputMode(32); } static /* synthetic */ String a(ztq ztq, Object obj) { String str = ztq.a + obj; ztq.a = str; return str; } static /* synthetic */ String a(ztq ztq, String str) { StringBuilder sb = new StringBuilder(str); if (!TextUtils.isEmpty(ztq.p) && ztq.p.length() >= 4) { sb.append("_u_").append(ztq.p.substring(ztq.p.length() - 4)); } return sb.toString(); } static /* synthetic */ void a(Context context, String str) { try { JSONObject agx = zuz.agx(str); int i2 = agx.getInt(VastExtensionXmlManager.TYPE); Toast.makeText(context.getApplicationContext(), agx.getString(NotificationCompat.CATEGORY_MESSAGE), i2).show(); } catch (JSONException e) { e.printStackTrace(); } } static /* synthetic */ boolean b(ztq ztq) { ztr gSE = ztr.gSE(); String c2 = ztr.c(); ztr.a aVar = new ztr.a(); aVar.BJE = ztq.BJz; aVar.BJW = ztq; aVar.c = c2; String a2 = gSE.a(aVar); String substring = ztq.a.substring(0, ztq.a.indexOf("?")); Bundle agv = zuz.agv(ztq.a); agv.putString("token_key", c2); agv.putString("serial", a2); agv.putString("browser", "1"); ztq.a = substring + "?" + zuq.ad(agv); return zuz.a(ztq.k, ztq.a); } static /* synthetic */ int m(ztq ztq) { int i2 = ztq.n; ztq.n = i2 + 1; return i2; } static /* synthetic */ String o(ztq ztq) { String str = "http://qzs.qq.com/open/mobile/login/qzsjump.html?" + ztq.a.substring(ztq.a.indexOf("?") + 1); zue.c("openSDK_LOG.AuthDialog", "-->generateDownloadUrl, url: http://qzs.qq.com/open/mobile/login/qzsjump.html?"); return str; } public final void dismiss() { this.BJS.clear(); this.d.removeCallbacksAndMessages(null); if (isShowing()) { super.dismiss(); } if (this.BJP != null) { this.BJP.destroy(); this.BJP = null; } } public final void onBackPressed() { if (!this.m) { this.BJK.onCancel(); } super.onBackPressed(); } /* access modifiers changed from: protected */ public final void onCreate(Bundle bundle) { requestWindowFeature(1); super.onCreate(bundle); this.BJO = new ProgressBar(this.k); this.BJO.setLayoutParams(new LinearLayout.LayoutParams(-2, -2)); this.BJM = new LinearLayout(this.k); TextView textView = null; if (this.i.equals("action_login")) { LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2); layoutParams.gravity = 16; layoutParams.leftMargin = 5; textView = new TextView(this.k); if (Locale.getDefault().getLanguage().equals("zh")) { textView.setText("登录中..."); } else { textView.setText("Logging in..."); } textView.setTextColor(Color.rgb(255, 255, 255)); textView.setTextSize(18.0f); textView.setLayoutParams(layoutParams); } FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(-2, -2); layoutParams2.gravity = 17; this.BJM.setLayoutParams(layoutParams2); this.BJM.addView(this.BJO); if (textView != null) { this.BJM.addView(textView); } this.BJN = new FrameLayout(this.k); FrameLayout.LayoutParams layoutParams3 = new FrameLayout.LayoutParams(-1, -2); layoutParams3.leftMargin = 80; layoutParams3.rightMargin = 80; layoutParams3.topMargin = 40; layoutParams3.bottomMargin = 40; layoutParams3.gravity = 17; this.BJN.setLayoutParams(layoutParams3); this.BJN.setBackgroundResource(17301504); this.BJN.addView(this.BJM); FrameLayout.LayoutParams layoutParams4 = new FrameLayout.LayoutParams(-1, -1); this.BJP = new com.tencent.open.c.c(this.k); if (Build.VERSION.SDK_INT >= 11) { this.BJP.setLayerType(1, null); } this.BJP.setLayoutParams(layoutParams4); this.BJL = new FrameLayout(this.k); layoutParams4.gravity = 17; this.BJL.setLayoutParams(layoutParams4); this.BJL.addView(this.BJP); this.BJL.addView(this.BJN); setContentView(this.BJL); this.BJP.setVerticalScrollBarEnabled(false); this.BJP.setHorizontalScrollBarEnabled(false); this.BJP.setWebViewClient(new a(this, (byte) 0)); this.BJP.setWebChromeClient(new WebChromeClient()); this.BJP.clearFormData(); this.BJP.clearSslPreferences(); this.BJP.setOnLongClickListener(new View.OnLongClickListener() { /* class defpackage.ztq.AnonymousClass1 */ public final boolean onLongClick(View view) { return true; } }); this.BJP.setOnTouchListener(new View.OnTouchListener() { /* class defpackage.ztq.AnonymousClass2 */ public final boolean onTouch(View view, MotionEvent motionEvent) { switch (motionEvent.getAction()) { case 0: case 1: if (view.hasFocus()) { return false; } view.requestFocus(); return false; default: return false; } } }); WebSettings settings = this.BJP.getSettings(); settings.setSavePassword(false); settings.setSaveFormData(false); settings.setCacheMode(-1); settings.setNeedInitialFocus(false); settings.setBuiltInZoomControls(true); settings.setSupportZoom(true); settings.setRenderPriority(WebSettings.RenderPriority.HIGH); settings.setJavaScriptEnabled(true); settings.setDatabaseEnabled(true); settings.setDatabasePath(this.k.getDir("databases", 0).getPath()); settings.setDomStorageEnabled(true); zue.a("openSDK_LOG.AuthDialog", "-->mUrl : " + this.a); this.o = this.a; this.BJP.loadUrl(this.a); this.BJP.setVisibility(4); this.BJP.getSettings().setSavePassword(false); this.BJQ.a(new zvc(), "SecureJsInterface"); zvc.BLx = false; super.setOnDismissListener(new DialogInterface.OnDismissListener() { /* class defpackage.ztq.AnonymousClass3 */ public final void onDismiss(DialogInterface dialogInterface) { try { JniInterface.clearAllPWD(); } catch (Exception e) { } } }); this.BJS = new HashMap<>(); } /* access modifiers changed from: protected */ public final void onStop() { super.onStop(); } }